<?php

namespace app\api\controller;

class Pushmsg
{
    public $pagesize = 10;

    /**
     * 获取我的消息列表数据接口
     */
    public function lists()
    {
        $auth = trim(input("request.auth"));//用户auth
        $userInfo = checkLoginExp($auth);
        if (empty($userInfo)) {
            $return = ['err' => 1, 'msg' => '获取失败,未登录', 'devMsg' => '获取失败，参数错误[auth]'];
            return json($return);
        }

        $pagesize = trim(input("pagesize"));//每页条数

        if (!empty($pagesize)) {
            $this->pagesize = $pagesize;
        }
        $page = trim(input("page"));//每页条数

        if (empty($page)) {
            $page=1;
        }
        $w = array();
        $w['is_delete'] = 0;//未删除
        $w['is_avail_push'] = 0;//可以推送
        $w['stats'] = 1;//可以推送

        $sql = "select id,uid,title,cont,fun,val,ctime,ptime,stats from t_push_msg
              where (uid=" . $userInfo['id'] . " or find_in_set(" . $userInfo['id'] . ",all_uid) ) order by id desc";
        $model = new \app\admin\model\PushMsg();
        $lists = $model->listsForSQL($sql,$this->pagesize,$page);
        $lists = $lists['data'];
        $return['err'] = 0;
        $return['msg'] = '获取成功';
        $return['data'] = $lists;
        return json($return);

    }
}
